package com.ruoyi.common.enums;

public enum RoleEnum {

    SUPER_ADMIN(1, "超级管理员"),
    TEAM_MEMBER(2, "队员"),
    JUDGE(3, "裁判"),
    SYSTEM(4, "系统管理员");

    private final int code;
    private final String description;

    RoleEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据 code 获取 description
    public static String getDescriptionByCode(int code) {
        for (RoleEnum role : RoleEnum.values()) {
            if (role.getCode() == code) {
                return role.getDescription();
            }
        }
        return null; // 如果找不到匹配的 code，可以返回 null 或其他默认值
    }

    public static RoleEnum getByCode(Long code) {
        for (RoleEnum role : RoleEnum.values()) {
            if (role.getCode() == code) {
                return role;
            }
        }
        return null; // 如果没有找到对应的枚举值，返回 null
    }
}
